package cn.zlb.frame.domain.merchant.service.impl;

import cn.zlb.frame.domain.merchant.model.MerchantAggregateRoot;
import cn.zlb.frame.domain.merchant.model.entity.MerchantEntity;
import cn.zlb.frame.domain.merchant.repository.gateway.IMerchantPaymentGateway;
import cn.zlb.frame.domain.merchant.repository.persistence.IMerchantDomainRepository;
import cn.zlb.frame.domain.merchant.service.IMerchantDomainService;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * @author yangjie.deng@resico.cn
 * @date 2023-11-14 14:33:33
 * @describe class responsibility
 */
@Service
public class MerchantDomainServiceImpl implements IMerchantDomainService {

    @Resource
    private IMerchantPaymentGateway merchantPaymentGateway;

    @Resource
    private IMerchantDomainRepository merchantDomainRepository;

    @Override
    public MerchantEntity createMerchant(MerchantAggregateRoot merchant) {
        // 获取商户附加信息
        final MerchantEntity merchantEntity = merchantPaymentGateway.merchantPayAttachmentFull(merchant.getMerchantEntity());
        // 保存商户信息
        return merchantDomainRepository.save(merchantEntity);
    }
}
